// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env:'online-00000'
})
const db = cloud.database()
const _=db.command
// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  let openid = wxContext.OPENID;
  if(event.openid){
    openid=event.openid
  }
  let pro =await db.collection('winners').where({
    openid
  }).count();

  return {
    status:pro.total==1?true:false
  }
}